/*This file is part of Sandbox.

Sandbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License.

Sandbox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Sandbox.  If not, see <http://www.gnu.org/licenses/>.

For contact, see the About page of my blog: <http://mygeekyware.wordpress.com/>.*/

#include <iostream>
#include "controlador.h"
#include "definiciones.h"
#include <SDL/SDL.h>
#include <SDL/SDL_events.h>

using namespace std;

void controlador::MenuDerecho(int x, int y) {
    controlador::keys = SDL_GetKeyState(NULL);
    if (y<=453) {
        
    }
    else if (y<=466) {

    }
    else if (y<=479) {

    }
    else if (y<=492) {

    }
    else if (y<=505) {

    }
    else if (y<=518) {

    }
    else if (y<=531) {

    }
    else if (y<=544) {

    }
    else if (y<=557) {
        if (mouse1pushed == 0) {
            if (x<=720 && speed > 1)
                speed /= 2;
            else if (x <= 720 && speed == 1)
                speed = 0;
            if (x>=753 && x <=763 && speed == 0)
                speed = 1;
            else if (x>=753 && x<=763 && speed < 16)
                speed *= 2;
        }
    }
    else if (y<=570) {
        if (mouse1pushed == 0) {
            if (x<=720 && brsize > 1)
                brsize--;
            else if (x>=780 && brsize < 9)
                brsize++;
        }
    }
    else if (y<=583) {
        reset = true;
    }
    else if (y<=600) {
        exit(0);
    }
}

void controlador::MenuIzquierdo(int x, int y, int br) {
    if (x<88) {
        if (y<=453) {
            if (br == 1) {
                brtype2 = CLEAR;
            }
            else
                brtype = CLEAR;
        }
        else if (y<=466) {
            if (br == 1) {
                brtype2 = WALL;
            }
            else
                brtype = WALL;
        }
        else if (y<=479) {
            if (br == 1) {
                brtype2 = WATER;
            }
            else
                brtype = WATER;
        }
        else if (y<=492) {
            if (br == 1) {
                brtype2 = SALT;
            }
            else
                brtype = SALT;
        }
        else if (y<=505) {
            if (br == 1) {
                brtype2 = SAND;
            }
            else
                brtype = SAND;
        }
        else if (y<=518) {
            if (br == 1) {
                brtype2 = FIRE;
            }
            else
                brtype = FIRE;
        }
        else if (y<=531) {
            if (br == 1) {
                brtype2 = SALTWATER;
            }
            else
                brtype = SALTWATER;
        }
        else if (y<=544) {
            if (br == 1) {
                brtype2 = STONE;
            }
            else
                brtype = STONE;
        }
        else if (y<=557) {
            if (br == 1) {
                brtype2 = EARTH;
            }
            else
                brtype = EARTH;
        }
        else if (y<=570) {
            if (br == 1) {
                brtype2 = ICE;
            }
            else
                brtype = ICE;
        }
        else if (y<=583) {
            if (br == 1) {
                brtype2 = MAGMA;
            }
            else
                brtype = MAGMA;
        }
        else if (y<=600) {
            if (br == 1) {
                brtype2 = FIREWORK;
            }
            else
                brtype = FIREWORK;
        }
    }
    else if (x<176) {
        if (y<=453) {
            if (br == 1)
                brtype2 = TORCH;
            else
                brtype = TORCH;
        }
        else if (y<=466) {
            if (br == 1)
                brtype2 = BOMB;
            else
                brtype = BOMB;
        }
        else if (y<=479) {
            if (br == 1)
                brtype2 = FUSE;
            else
                brtype = FUSE;
        }
        else if (y<=492) {
            if (br == 1)
                brtype2 = OIL;
            else
                brtype = OIL;
        }
    }
}